package com.dtw.ditouwang.ui.mine;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dtw.ditouwang.R;
import com.dtw.ditouwang.beans.AssetsBean;

import java.util.List;

public class AssetsAdapter extends RecyclerView.Adapter<AssetsAdapter.Holder> {
    private List<AssetsBean.DataBean.ListBean> assetsBeanlist;

    public AssetsAdapter(List<AssetsBean.DataBean.ListBean> assetsBeanlist) {
        this.assetsBeanlist = assetsBeanlist;
    }

    @NonNull
    @Override
    public Holder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new Holder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_assetes, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int i) {
        holder.name.setText(assetsBeanlist.get(i).getContent());
        holder.count.setText(assetsBeanlist.get(i).getInfo()+assetsBeanlist.get(i).getNumber() + "");
        holder.time.setText(assetsBeanlist.get(i).getTimes());
    }

    @Override
    public int getItemCount() {
        return assetsBeanlist.size();
    }

    class Holder extends RecyclerView.ViewHolder {
        TextView name, time, count;

        public Holder(@NonNull View itemView) {
            super(itemView);
            name = itemView.findViewById(R.id.text_name);
            time = itemView.findViewById(R.id.text_time);
            count = itemView.findViewById(R.id.text_count);
        }
    }
}
